import { Table } from 'antd';

const TableList = ({ 
    dataSource,
    columns,
    total,
    rowKey = 'id',
    onPageChange,
    onShowSizeChange, 
}) => {
    return (
        <Table 
            dataSource={dataSource} 
            columns={columns}
            rowKey={rowKey}
            pagination={{
                total: total,
                showTotal: (total) => {return `共 ${total} 条`},
                showSizeChanger: true,
                showQuickJumper: true,
                onChange: (page) => {
                    if (onPageChange) {
                        onPageChange(page)
                    }
                },
                onShowSizeChange: (current, size) => {
                    if (onShowSizeChange) {
                        onShowSizeChange(current, size);
                    }
                }
            }}
        ></Table>
    )
}

export default TableList;